﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace XiuxianGame.图形资源库.组件
{
    public partial class ProgressColorBar : ProgressBar
    {

        Color fcolor = Color.Black;
        Color bcolor = Color.White;

        public Color Fcolor { get => fcolor; set => fcolor = value; }
        public Color Bcolor { get => bcolor; set => bcolor = value; }

        public ProgressColorBar()
        {
            base.SetStyle(ControlStyles.UserPaint, true);

        }

        //重写OnPaint方法
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle bounds = new Rectangle(0, 0, base.Width, base.Height);
            Graphics graphics = e.Graphics;
            //...
            if (graphics == null)
            {
                graphics = this.CreateGraphics();
            }
            //e.Graphics.FillRectangle(new SolidBrush(this.BackColor), 1, 1, bounds.Width - 2, bounds.Height - 2);
            graphics.FillRectangle(new SolidBrush(Bcolor), 1, 1, bounds.Width - 2, bounds.Height - 2);
            bounds.Height -= 4;
            bounds.Width = ((int)(bounds.Width * (((double)Value) / ((double)Maximum)))) - 4;
            graphics.FillRectangle(new SolidBrush(Fcolor), 2, 2, bounds.Width, bounds.Height);
        }

    }
}
